package com.atguigu;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service(value = "accountService")
public class AccountServiceImpl implements IAccountService {
	
	@Resource(name = "accountMapper")
	private AccountMapper accountMapper;

	@Transactional
	public int addAccount(Account dt) {
		accountMapper.addAccount(dt);
		return 0;
	}
	
	public List<Account> findAll(){
		List<Account> l = null;
		try {
			l = accountMapper.findAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return l;
	};
	
	@Transactional
	public int deleteByAccountId(int id){
		accountMapper.deleteByAccountId(id);
		return 0;
	};
	
	public boolean findByName(String name) {
		List<Account> d = accountMapper.findByName(name);
		if(d == null || d.size() == 0) {
			return false;
		}else {
			return true;
		}
	}


}
